<!--
 * @Description: 地图弹出框
 * @Author: 0001100986/LiuShuai
 * @Date: 2021-07-09 14:04:42
 * @LastEditTime: 2021-08-23 17:49:57
 * @LastEditors: 0001100986/LiuShuai
-->
<template>
  <div class="dialogbg" v-show="dialogVisible">
    <div :class="nelength === 1 ? 'dialogboxs' : 'dialogbox'">
      <div class="box-title">
        {{info.name}}
        <i class="el-icon-close" @click="cancel"></i>
      </div>
      <div class="box-content">
        <ul>
          <li v-for="(item, index) in info.nes" :key="index" @click="goInfo(item)">
            <template v-if="item.neLayer === 'Access'">
              <img src="/static/images/cpe.png" />
            </template>
            <template v-else>
              <img src="/static/images/pop.png" />
            </template>
            <div v-show="item.managementState === 'ONLINE'">
              <span v-if="item.connectionState === 'CONNECTED'">
                <i class="i-success"></i>
                {{item.userlabel}}
              </span>
              <span v-if="item.connectionState === 'DISCONNECTED'">
                <i class="i-error"></i>
                {{item.userlabel}}
              </span>
            </div>
            <span v-show="item.connectionState === 'UNKNOWN'">
              <i class="i-warning"></i>
              {{item.userlabel}}
            </span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'markDialog',
  props: ['dialogVisible', 'info'],
  data () {
    return {
      nelength: 1
    };
  },
  watch: {
    info (val) {
      let _this = this;
      _this.nelength = val.nes.length;
    }
  },
  mounted () {
    // 监听键盘按键事件
    let _this = this;
    _this.$nextTick(function() {
      document.addEventListener('keyup', function(e) {
        // 监听ESC按钮
        if (e.keyCode === 27) {
          _this.$emit('changeDialog', false);
        }
      });
    });
  },
  methods: {
    // 跳转详情页
    goInfo (data) {
      if (data.connectionState === 'CONNECTED' && data.managementState === 'ONLINE') {
        localStorage.setItem('monitor', data.id);
        // 根据ID查询网元相关信息
        this.$router.push({
          path: `/monitor/device-info`,
          query: {
            id: data.id
          }
        });
      } else {
        this.$message.error('网元状态异常！');
      }
    },
    // 取消关闭
    cancel () {
      let _this = this;
      _this.$emit('changeDialog', false);
    }
  }
};
</script>

<style lang="scss" scoped>
.dialogbg {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: transparent;
  height: 100%;
  z-index: 99;
  overflow: auto;
  .dialogbox {
    width: 280px;
    margin: 0 auto;
    position: relative;
    outline: 0;
    top: 30%;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    color: #fff;
    border: 1px solid rgba(25, 186, 139, 0.17);
    padding: 0 0.3rem 0.3rem 0.3rem;
    background: rgba(255, 255, 255, 0.04) url("/static/images/line.png");
    .box-title {
      height: 30px;
      line-height: 30px;
      font-size: 14px;
      font-weight: 500;
      padding: 10px 16px 5px 16px;
      overflow: hidden;
      background-color: transparent;
      border-bottom: 1px solid #3ed4ff;
      &::before,
      &::after {
        position: absolute;
        width: 0.6rem;
        height: 0.6rem;
        content: "";
        border-top: 2px solid #3ed4ff;
        top: 5px;
      }
      &::before {
        border-left: 2px solid #3ed4ff;
        left: 4px;
      }
      &::after {
        border-right: 2px solid #3ed4ff;
        right: 4px;
      }
      i {
        float: right;
        color: #3ed4ff;
        font-size: 14px;
        font-weight: 700;
        position: relative;
        top: 8px;
        right: 0;
        cursor: pointer;
        &::after {
          clear: both;
          content: "";
          overflow: hidden;
        }
      }
    }
    .box-content {
      position: relative;
      line-height: 24px;
      word-break: break-all;
      overflow: hidden;
      font-size: 14px;
      overflow-x: hidden;
      overflow-y: auto;
      padding: 0 16px;
      &::before,
      &::after {
        position: absolute;
        width: 0.6rem;
        height: 0.6rem;
        content: "";
        border-bottom: 2px solid #3ed4ff;
        bottom: 0;
      }
      &::before {
        border-left: 2px solid #3ed4ff;
        left: 0;
      }
      &::after {
        border-right: 2px solid #3ed4ff;
        right: 0;
      }
      ul {
        display: inline-block;
        width: 100%;
        li {
          float: left;
          width: 50%;
          text-align: center;
          cursor: pointer;
          &:hover {
            span {
              color: #3ed4ff;
            }
          }
          &:last-child::after {
            clear: both;
            content: "";
            overflow: hidden;
          }
          span {
            font-size: 12px;
          }
        }
      }
      img {
        display: block;
        width: 60px;
        height: 60px;
        margin: 0 auto;
        margin-top: 10px;
      }
      i {
        position: relative;
        display: inline-block;
        border-radius: 50%;
        width: 10px;
        height: 10px;
        top: 0;
        left: -5px;
        &.i-success {
          background: #19be6b;
        }
        &.i-error {
          background: #ed4014;
        }
        &.i-warning {
          background: #f90;
        }
        @keyframes scale {
          0% {
            transform: scale(1.1);
          }
          50%,
          75% {
            transform: scale(1.3);
          }
          78%,
          100% {
            opacity: 0;
          }
        }
        @keyframes scales {
          0% {
            transform: scale(1.1);
          }
          50%,
          75% {
            transform: scale(1.5);
          }
          78%,
          100% {
            opacity: 0;
          }
        }
      }
      i::before {
        position: absolute;
        top: -1px;
        left: -1px;
        content: "";
        display: block;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        opacity: 0.6;
        animation: scale 3s infinite cubic-bezier(0, 0, 0.49, 1.02);
      }
      .i-success::before {
        background: #19be6b;
      }
      .i-error::before {
        background: #ed4014;
      }
      .i-warning::before {
        background: #f90;
      }
    }
  }
  .dialogboxs {
    width: 200px;
    margin: 0 auto;
    position: relative;
    outline: 0;
    top: 30%;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    color: #fff;
    border: 1px solid rgba(25, 186, 139, 0.17);
    padding: 0 0.3rem 0.3rem 0.3rem;
    background: rgba(255, 255, 255, 0.04) url("/static/images/line.png");
    .box-title {
      height: 30px;
      line-height: 30px;
      font-size: 14px;
      font-weight: 500;
      padding: 10px 16px 5px 16px;
      overflow: hidden;
      background-color: transparent;
      border-bottom: 1px solid #3ed4ff;
      &::before,
      &::after {
        position: absolute;
        width: 0.6rem;
        height: 0.6rem;
        content: "";
        border-top: 2px solid #3ed4ff;
        top: 5px;
      }
      &::before {
        border-left: 2px solid #3ed4ff;
        left: 4px;
      }
      &::after {
        border-right: 2px solid #3ed4ff;
        right: 4px;
      }
      i {
        float: right;
        color: #3ed4ff;
        font-size: 14px;
        font-weight: 700;
        position: relative;
        top: 8px;
        right: 0;
        cursor: pointer;
        &::after {
          clear: both;
          content: "";
          overflow: hidden;
        }
      }
    }
    .box-content {
      position: relative;
      line-height: 24px;
      word-break: break-all;
      overflow: hidden;
      font-size: 14px;
      overflow-x: hidden;
      overflow-y: auto;
      padding: 0 16px;
      &::before,
      &::after {
        position: absolute;
        width: 0.6rem;
        height: 0.6rem;
        content: "";
        border-bottom: 2px solid #3ed4ff;
        bottom: 0;
      }
      &::before {
        border-left: 2px solid #3ed4ff;
        left: 0;
      }
      &::after {
        border-right: 2px solid #3ed4ff;
        right: 0;
      }
      ul {
        display: inline-block;
        width: 100%;
        li {
          float: left;
          width: 100%;
          text-align: center;
          cursor: pointer;
          &:hover {
            span {
              color: #3ed4ff;
            }
          }
          &:last-child::after {
            clear: both;
            content: "";
            overflow: hidden;
          }
          span {
            font-size: 12px;
          }
        }
      }
      img {
        display: block;
        width: 60px;
        height: 60px;
        margin: 0 auto;
        margin-top: 10px;
      }
      i {
        position: relative;
        display: inline-block;
        border-radius: 50%;
        width: 10px;
        height: 10px;
        top: 0;
        left: -5px;
        &.i-success {
          background: #19be6b;
        }
        &.i-error {
          background: #ed4014;
        }
        &.i-warning {
          background: #f90;
        }
        @keyframes scale {
          0% {
            transform: scale(1.1);
          }
          50%,
          75% {
            transform: scale(1.3);
          }
          78%,
          100% {
            opacity: 0;
          }
        }
        @keyframes scales {
          0% {
            transform: scale(1.1);
          }
          50%,
          75% {
            transform: scale(1.5);
          }
          78%,
          100% {
            opacity: 0;
          }
        }
      }
      i::before {
        position: absolute;
        top: -1px;
        left: -1px;
        content: "";
        display: block;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        opacity: 0.6;
        animation: scale 3s infinite cubic-bezier(0, 0, 0.49, 1.02);
      }
      .i-success::before {
        background: #19be6b;
      }
      .i-error::before {
        background: #ed4014;
      }
      .i-warning::before {
        background: #f90;
      }
    }
  }
}
</style>